<template>
	<Container>
		<Back :toHome="toHome" />
		<EditorIcon v-if="hasMerchant || hasExpert" type="note" :sceneId="detailData.id" />
		<Detail :detailData="detailData" />
		<Comment v-if="commentIsShow" scene="note" :sceneId="detailData.id" :scrollTop="scrollTop" />
	</Container>
</template>

<script>
import Detail from '../../components/detail/detail.vue'
import Comment from '../../components/comment/comment.vue'
import EditorIcon from '../../components/editorIcon/editorIcon.vue'
export default {
	data() {
		return {
			detailData: {},
			scrollTop: 0,
			hasMerchant: this.hasMerchant,
			hasExpert: this.hasExpert,
			commentIsShow: true,
			toHome: false
		}
	},
	onShareAppMessage() {
		let item = JSON.stringify(this.detailData)
		item = item.replace(/&nbsp;/g, ' ')
		return {
			title: this.detailData.title,
			path: '/pages/note/noteDetail?type=share&item=' + item,
			imageUrl: ''
		}
	},
	onLoad(option) {
		console.log('a');
		if (option.type === 'share') {
			this.toHome = true
			this.detailData = JSON.parse(option.item)
		} else {
			this.detailData = JSON.parse(decodeURIComponent(option.item))
		}
		if (this.detailData.type === 'test') {
			this.commentIsShow = false
			this.hasMerchant = false
		}
	},
	components: { Detail, Comment, EditorIcon },
	onPageScroll: function(res) {
		this.scrollTop = res.scrollTop
	}
}
</script>

<style scoped lang="stylus"></style>
